Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filebeat gcs input addFiledJobs panic protection #38407

Merged
merged 3 commits into from
Mar 20, 2024
Merged

Conversation

adassow
Copy link
Contributor

@adassow adassow commented Mar 19, 2024

In case obj, err := s.bucket.Object(name).Attrs(ctx) return an error, obj will be probably nil in consequence the code below will panic
objectURI := "gs://" + s.src.BucketName + "/" + obj.Name

Proposed commit message

Filebeat gcs input addFiledJobs panic protection

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

No idea

How to test this PR locally

No idea

Related issues

No idea

Use cases

No idea

Screenshots

Logs

Input crashed with: input panic with: runtime error: invalid memory address or nil pointer dereference
goroutine 938 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x65
github.com/elastic/beats/v7/filebeat/input/v2/input-cursor.(*managedInput).runSource.func1()
	github.com/elastic/beats/v7/filebeat/input/v2/input-cursor/input.go:143 +0x5d
panic({0x558d0f92f8a0, 0x558d123846f0})
	runtime/panic.go:884 +0x213
github.com/elastic/beats/v7/x-pack/filebeat/input/gcs.(*scheduler).addFailedJobs(0xc002e6cb40, {0x558d1007a820, 0xc002e720a0}, {0xc0042de240, 0x3, 0x4})
	github.com/elastic/beats/v7/x-pack/filebeat/input/gcs/scheduler.go:238 +0x378
github.com/elastic/beats/v7/x-pack/filebeat/input/gcs.(*scheduler).scheduleOnce(0xc002e6cb40, {0x558d1007a820?, 0xc002e720a0})
	github.com/elastic/beats/v7/x-pack/filebeat/input/gcs/scheduler.go:106 +0x2d3
github.com/elastic/beats/v7/x-pack/filebeat/input/gcs.(*scheduler).schedule(0xc002e6cb40, {0x558d1007a820?, 0xc002e720a0})
	github.com/elastic/beats/v7/x-pack/filebeat/input/gcs/scheduler.go:60 +0x65
github.com/elastic/beats/v7/x-pack/filebeat/input/gcs.(*gcsInput).Run(_, {0xc006f6a490, {0xc002e70000, 0x86}, {{0x558d0eae5cfe, 0x8}, {0x558d0eae5cfe, 0x8}, {0x558d0eadf24e, 0x6}, ...}, ...}, ...)
	github.com/elastic/beats/v7/x-pack/filebeat/input/gcs/input.go:183 +0x885
github.com/elastic/beats/v7/filebeat/input/v2/input-cursor.(*managedInput).runSource(_, {0xc006f6a490, {0xc002e70000, 0x86}, {{0x558d0eae5cfe, 0x8}, {0x558d0eae5cfe, 0x8}, {0x558d0eadf24e, 0x6}, ...}, ...}, ...)
	github.com/elastic/beats/v7/filebeat/input/v2/input-cursor/input.go:168 +0x479
github.com/elastic/beats/v7/filebeat/input/v2/input-cursor.(*managedInput).Run.func1()
	github.com/elastic/beats/v7/filebeat/input/v2/input-cursor/input.go:122 +0x1bf
github.com/elastic/go-concert/unison.(*MultiErrGroup).Go.func1()
	github.com/elastic/[email protected]/unison/multierrgroup.go:42 +0x75
created by github.com/elastic/go-concert/unison.(*MultiErrGroup).Go
	github.com/elastic/[email protected]/unison/multierrgroup.go:40 +0x8d

In case `obj, err := s.bucket.Object(name).Attrs(ctx)` return an error, obj will be probably `nil` in consequence the code below will panic
`objectURI := "gs://" + s.src.BucketName + "/" + obj.Name`
@adassow adassow requested a review from a team as a code owner March 19, 2024 07:18
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Mar 19, 2024
Copy link

cla-checker-service bot commented Mar 19, 2024

💚 CLA has been signed

Copy link
Contributor

mergify bot commented Mar 19, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @adassow? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 19, 2024

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Duration: 137 min 43 sec

❕ Flaky test report

No test was executed to be analysed.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@adassow adassow removed their assignment Mar 19, 2024
@adassow
Copy link
Contributor Author

adassow commented Mar 19, 2024

This pull request does not have a backport label. If this is a bug or security fix, could you label this PR @adassow? 🙏. For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

It seems I don't have permission to add any label. It's a bugfix and doesn't change anything except protecting against panic. It shout go probably as a patch.

@ShourieG
Copy link
Contributor

/test

@ShourieG ShourieG added the Team:Security-Service Integrations Security Service Integrations Team label Mar 19, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Mar 19, 2024
@ShourieG ShourieG added needs_team Indicates that the issue/PR needs a Team:* label backport-v8.12.0 Automated backport with mergify labels Mar 19, 2024
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Mar 19, 2024
@ShourieG
Copy link
Contributor

ShourieG commented Mar 19, 2024

Hi @adassow, thanks for the PR, will get it merged asap. Could you please add an entry in CHANGELOG-developer.next.asciidoc, that would be great.

@ShourieG ShourieG added the backport-v8.13.0 Automated backport with mergify label Mar 19, 2024
Copy link
Contributor

@ShourieG ShourieG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ShourieG ShourieG enabled auto-merge (squash) March 19, 2024 10:28
auto-merge was automatically disabled March 19, 2024 11:04

Head branch was pushed to by a user without write access

Copy link
Contributor

@ShourieG ShourieG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@ShourieG ShourieG enabled auto-merge (squash) March 19, 2024 12:36
@ShourieG ShourieG disabled auto-merge March 19, 2024 14:33
@ShourieG ShourieG enabled auto-merge (squash) March 19, 2024 14:35
@adassow
Copy link
Contributor Author

adassow commented Mar 20, 2024

@ShourieG How can I satisfy buildkite/docs-build-pr check?

@ShourieG
Copy link
Contributor

@ShourieG How can I satisfy buildkite/docs-build-pr check?

@adassow There seems to be a CI issue on our end, the CI team is looking into it. As soon as it's resolved we'll merge.

@karenzone
Copy link
Contributor

buildkite test this rebuild

@@ -92,6 +92,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Make winlogbeat/sys/wineventlog follow the unsafe.Pointer rules. {pull}36650[36650]
- Cleaned up documentation errors & fixed a minor bug in Filebeat Azure blob storage input. {pull}36714[36714]
- Fix copy arguments for strict aligned architectures. {pull}36976[36976]
- Fix filebit gcs input panic {pull}38407[38407]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entry should be added to CHANGELOG.next.asciidoc. The "developer" file is focused mainly on API changes or internal-only fixes (without a user impact).

filebit -> filebeat

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create a PR to shift this around, since auto merge was enabled and it got merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShourieG ShourieG merged commit c6fd99c into elastic:main Mar 20, 2024
22 checks passed
mergify bot pushed a commit that referenced this pull request Mar 20, 2024
* Filebeat gcs input addFiledJobs panic protection

In case `obj, err := s.bucket.Object(name).Attrs(ctx)` return an error, obj will be probably `nil` in consequence the code below will panic
`objectURI := "gs://" + s.src.BucketName + "/" + obj.Name`

* Update CHANGELOG-developer.next.asciidoc

(cherry picked from commit c6fd99c)
mergify bot pushed a commit that referenced this pull request Mar 20, 2024
* Filebeat gcs input addFiledJobs panic protection

In case `obj, err := s.bucket.Object(name).Attrs(ctx)` return an error, obj will be probably `nil` in consequence the code below will panic
`objectURI := "gs://" + s.src.BucketName + "/" + obj.Name`

* Update CHANGELOG-developer.next.asciidoc

(cherry picked from commit c6fd99c)
ShourieG added a commit that referenced this pull request Mar 21, 2024
…ion (#38475)

* Filebeat gcs input addFiledJobs panic protection (#38407)

* Filebeat gcs input addFiledJobs panic protection

In case `obj, err := s.bucket.Object(name).Attrs(ctx)` return an error, obj will be probably `nil` in consequence the code below will panic
`objectURI := "gs://" + s.src.BucketName + "/" + obj.Name`

* Update CHANGELOG-developer.next.asciidoc

(cherry picked from commit c6fd99c)

* Update CHANGELOG-developer.next.asciidoc

---------

Co-authored-by: Adam Sowiński <[email protected]>
Co-authored-by: ShourieG <[email protected]>
ShourieG added a commit that referenced this pull request Mar 21, 2024
…ion (#38474)

* Filebeat gcs input addFiledJobs panic protection (#38407)

* Filebeat gcs input addFiledJobs panic protection

In case `obj, err := s.bucket.Object(name).Attrs(ctx)` return an error, obj will be probably `nil` in consequence the code below will panic
`objectURI := "gs://" + s.src.BucketName + "/" + obj.Name`

* Update CHANGELOG-developer.next.asciidoc

(cherry picked from commit c6fd99c)

* Update CHANGELOG-developer.next.asciidoc

---------

Co-authored-by: Adam Sowiński <[email protected]>
Co-authored-by: ShourieG <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.13-candidate backport-v8.12.0 Automated backport with mergify backport-v8.13.0 Automated backport with mergify bugfix Team:Security-Service Integrations Security Service Integrations Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants